Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6783 Fix that removing a tag nomination would result in a blank tag nomination #4888

Merged
merged 6 commits into from
Aug 4, 2024

Conversation

Bilka2
Copy link
Contributor

@Bilka2 Bilka2 commented Aug 3, 2024

Issue

https://otwarchive.atlassian.net/browse/AO3-6783

Purpose

If a tag nomination is blank (empty string for tagname) because it is meant to be destroyed, don't modify it in before_save and exclude it from certain validations.

Tag.find_by(name: "") where name is an empty string returns the broken blank tag. Tag nominations that are meant to be removed have an empty string for the tag name. So, Tag.find_by_name(tagname) in TagNomination's before_save :set_tag_status returns the broken blank tag and its name is used to set the TagNomination.tagname. This means the nomination that was meant to be destroyed by after_save :destroy_if_blank is no longer blank, instead it contains all the information from the broken blank tag so it doesn't get destroyed. There is no way to get rid of this tag nomination, since any attempt to clear the tagname field will repeat this process. The only way to escape the broken blank tag is by renaming the nomination to a completely different tag name, but that still keeps the unwanted tag nomination around.

The problem of the DB returning the broken tag also affects the autocomplete, so I've also added the bypass there.

While investigating which callbacks to skip, I noticed that validate :known_fandom on CastNomination would run for nominations about to be destroyed, so you needed to keep Fandom? filled out if you wanted to remove a character or relationship nomination in a tag set that doesn't allow fandom nominations. That's also fixed by skipping it for blank tagnames, so I went ahead and changed it.

Testing Instructions

See Jira.

References

The database returning the zero width space tag when querying for an empty string is potentially caused by the database collation. However, the comments on AO3-6366 indicates that changing this collation would be a complicated endeavor. So this PR can serve as a workaround to get rid of the incredibly annoying behaviour currently happening on production until it's clear whether changing the collation fixes the underlying issue.

Note that all tests I added here (with the exception of Scenario: Zero width space tag appears in the autocomplete for zero width space) fail before the changes in this PR. So users on production are likely hitting the confusing "Someone else has already nominated the tag for this set but in fandom ...." error in Scenario: A tag nomination with for the zero width space tag doesn't prevent removing other tag nominations.

Credit

Bilka (he/him)

@Bilka2 Bilka2 changed the title Ao3 6783 blank tag nomination AO3-6783 Fix that removing a tag nomination would result in a blank tag nomination Aug 3, 2024
@sarken sarken merged commit cd20f8e into otwcode:master Aug 4, 2024
28 of 29 checks passed
@Bilka2 Bilka2 deleted the AO3-6783-blank-tag-nomination branch August 4, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants